package cn.getech.data.development.constant;

import lombok.Getter;
import org.apache.commons.lang.StringUtils;

@Getter
public enum TableDataHeaderType {

    fieldName("fieldName","字段名称",0),
    fieldType("fieldType","字段类型",1),
    fieldAlias ("fieldAlias","字段描述",2),
    isPartition ("isPartition","是否为分区字段[0：否，1：是]",3),
    fieldOrder("fieldOrder","字段序号",4);

    TableDataHeaderType(String name, String desc, int code) {
        this.name = name;
        this.desc = desc;
        this.code = code;
    }


    private String name;
    private String desc;
    private Integer code;


    public static TableDataHeaderType ObjOf(Integer code) {
        if (code == null) {
            return null;
        } else {
            for (TableDataHeaderType s : TableDataHeaderType.values()) {
                if (s.getCode() == code) {
                    return s;
                }
            }
            return null;
        }
    }

    public static TableDataHeaderType objOf(String desc){
        if (StringUtils.isBlank(desc)) {
            return null;
        } else {
            for (TableDataHeaderType s : TableDataHeaderType.values()) {
                if (s.getDesc().equals(desc)) {
                    return s;
                }
            }
            return null;
        }
    }

}
